package ro.pub.cs.stadium.document.logic;

import java.util.ArrayList;

import ro.pub.cs.stadium.document.AbstractTransition;
import ro.pub.cs.stadium.document.IState;
import ro.pub.cs.stadium.document.ITransition;
import ro.pub.cs.stadium.document.IDocument;;

public class Transition extends AbstractTransition {

	private IState startState, endState;
	private Expression condition;
	
	public Transition(String name, State start, State stop)	{
		setName(name);
		startState = start;
		start.getOutTransitions().put(name, this);
		endState = stop;
		stop.getInTransitions().put(name, this);
		setAttribute("type", "transition");
		setAttribute("start state", startState.toString());
		setAttribute("end state", endState.toString());
	}
	
	public IState getEndPoint() {
		return endState;
	}

	public IState getStartPoint() {
		return startState;
	}
	
	public void setCondition(String cond) throws ExpressionException {
		condition = new Expression(cond);
		setAttribute("condition", condition.toString());
	}
	
	public Expression getCondition() {
		return condition;
	}

	public void setEndPoint(IState state) {
		endState = state;
		
	}

	public void setStartPoint(IState state) {
		startState = state;
		
	}

}
